using MicroMsg.UI.Util;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class ProfileTxtContentCtrl : ProfileInfoItemBase
	{
		public delegate void ListItemClick(object sender, object object_0);
		private const string TAG = "ProfileTxtContentCtrl";
		private const int cNMaxCacheCnt = 5;
		private bool mBIsFirstLoaded = true;
		private static List<ProfileTxtContentCtrl> sItemsCached = new List<ProfileTxtContentCtrl>();
		internal StackPanel LayoutRoot;
		internal StackPanel panelTitle;
		internal TextBlock txtAreaTitle;
		internal ClickEffectGrid btnContent;
		internal EmojiText txtNicks;
		internal TextBlock txtStaticText;
		private bool _contentLoaded;
		public event ProfileTxtContentCtrl.ListItemClick ItemClick;
		public ProfileTxtContentCtrl()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.Control_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.Control_Unloaded));
			base.set_Visibility(1);
		}
		private void Control_Loaded(object sender, RoutedEventArgs e)
		{
		}
		private void Control_Unloaded(object sender, RoutedEventArgs e)
		{
		}
		private void btnLayoutRoot_Click(object sender, RoutedEventArgs e)
		{
		}
		protected override void RefreshItem()
		{
			if (base.InfoData == null)
			{
				base.set_Visibility(1);
				return;
			}
			base.set_Visibility(0);
			this.txtAreaTitle.set_Text(base.InfoData.mStrTitle);
			this.txtNicks.Text = base.InfoData.mStrInfo1;
			this.txtStaticText.set_Text(base.InfoData.mStrInfo2);
			if (string.IsNullOrEmpty(this.txtNicks.Text))
			{
				this.txtNicks.set_Visibility(1);
			}
			else
			{
				this.txtNicks.set_Visibility(0);
			}
			ProfileInfoKind arg_90_0 = base.InfoData.mInfoKind;
		}
		public void SetContent(string strTitle, string strInfo1, string strInfo2 = null, ProfileInfoKind infoKind = ProfileInfoKind.Kind_None)
		{
			ProfileInfoData infoData = new ProfileInfoData
			{
				mStrTitle = strTitle,
				mStrInfo1 = strInfo1,
				mStrInfo2 = strInfo2,
				mInfoKind = infoKind
			};
			base.InfoData = infoData;
		}
		public override void Collect()
		{
			base.InfoData = null;
			base.set_Visibility(1);
			this.txtAreaTitle.set_Text("");
			this.txtNicks.Text = "";
			this.txtStaticText.set_Text("");
		}
		public static ProfileTxtContentCtrl GetOneItem()
		{
			if (ProfileTxtContentCtrl.sItemsCached != null && ProfileTxtContentCtrl.sItemsCached.get_Count() != 0)
			{
				ProfileTxtContentCtrl profileTxtContentCtrl = Enumerable.First<ProfileTxtContentCtrl>(ProfileTxtContentCtrl.sItemsCached);
				ProfileTxtContentCtrl.sItemsCached.RemoveAt(0);
				if (profileTxtContentCtrl.get_Parent() == null)
				{
					return profileTxtContentCtrl;
				}
			}
			return new ProfileTxtContentCtrl();
		}
		public static int GetCacheCnt()
		{
			if (ProfileTxtContentCtrl.sItemsCached == null)
			{
				return 0;
			}
			return ProfileTxtContentCtrl.sItemsCached.get_Count();
		}
		public static void PushOneItem(ProfileTxtContentCtrl item)
		{
			if (item == null)
			{
				return;
			}
			if (ProfileTxtContentCtrl.sItemsCached == null)
			{
				ProfileTxtContentCtrl.sItemsCached = new List<ProfileTxtContentCtrl>();
			}
			if (item.get_Parent() != null)
			{
				Panel panel = item.get_Parent() as Panel;
				if (panel != null)
				{
					panel.get_Children().Remove(item);
				}
			}
			item.Collect();
			if (ProfileTxtContentCtrl.sItemsCached.get_Count() >= 5)
			{
				return;
			}
			ProfileTxtContentCtrl.sItemsCached.Add(item);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Contact/ProfileInfo/ProfileTxtContentCtrl.xaml", 2));
			this.LayoutRoot = (StackPanel)base.FindName("LayoutRoot");
			this.panelTitle = (StackPanel)base.FindName("panelTitle");
			this.txtAreaTitle = (TextBlock)base.FindName("txtAreaTitle");
			this.btnContent = (ClickEffectGrid)base.FindName("btnContent");
			this.txtNicks = (EmojiText)base.FindName("txtNicks");
			this.txtStaticText = (TextBlock)base.FindName("txtStaticText");
		}
	}
}
